﻿
#include "MyVtkAxesActor.h"
#include <vtkPlaneSource.h>
#include <vtkTexture.h>
#include <vtkArrowSource.h>
#include <vtkTriangle.h>
#include <vtkPNGReader.h>
#include <vtkAxesActor.h>
#include <vtkTextProperty.h>
#include <vtkFollower.h>
#include <vtkTextActor.h>
#include <vtkBillboardTextActor3D.h>
#include <vtkVectorText.h>




MyVtkAxesActor::MyVtkAxesActor():vtkAssembly()
{
    m_pDirectionInfoKey = vtkInformationDoubleVectorKey::MakeKey("direction", "direction", 6);

    CereateAxesArrow();
    CereateFace();
    CereateEdgeFace();
    CereateVertexFace();
}

MyVtkAxesActor::~MyVtkAxesActor()
{
    if( m_pDirectionInfoKey )
    {

        delete m_pDirectionInfoKey;
        m_pDirectionInfoKey = nullptr;
    }

}

MyVtkAxesActor* MyVtkAxesActor::New()
{
    return new MyVtkAxesActor;
}

void MyVtkAxesActor::SetControledRenderer(vtkRenderer* pRenderer)
{
    m_pContoledRenderer = pRenderer;
}

vtkRenderer* MyVtkAxesActor::GetControledRenderer() const
{
    return m_pContoledRenderer;
}

void MyVtkAxesActor::SetRenderWindowInteractor(vtkRenderWindowInteractor* pRenderWindowInteractor)
{
    m_pRenderWindowInteractor = pRenderWindowInteractor;
}

void MyVtkAxesActor::SetAxesMarkerWidget(MyVtkOrientationMarkerWidget* pAxesMarkerWidget)
{
    m_pAxesMarkerWidget = pAxesMarkerWidget;

    if( !m_pAxesMarkerWidget )
    {
        return;
    }

    auto renderer = m_pAxesMarkerWidget->GetRenderer();
    if( !renderer )
    {
        return;
    }

    for( auto label : m_vecLabels )
    {
        label->SetCamera(renderer->GetActiveCamera());
        renderer->AddActor(label);
    }
}

MyVtkOrientationMarkerWidget* MyVtkAxesActor::GetAxesMarkerWidget() const
{
    return m_pAxesMarkerWidget;
}

void MyVtkAxesActor::AddActor(vtkActor* actor)
{
    this->AddPart(actor);
    m_vecActors.push_back(actor);
}

void MyVtkAxesActor::GetActors(std::vector<vtkActor*>& actors)
{
    actors.clear();
    actors = m_vecActors;
}

void MyVtkAxesActor::AddLabel(vtkSmartPointer<vtkFollower> label)
{
    m_vecLabels.push_back(label);
}


void MyVtkAxesActor::CereateAxesArrow()
{
    //x-axis
    double xColor[3] = { 1.0, 0.0, 0.0 };
    auto xActor = CreateArrowActor(E_DIRECTION_X_PLUS, xColor);
    AddActor(xActor);

    //y-axis
    double yColor[3] = { 0.0, 1.0, 0.0 };
    auto yActor = CreateArrowActor(E_DIRECTION_Y_PLUS, yColor);
    AddActor(yActor);

    //z-axis        
    double zColor[3] = { 0.0, 0.0, 1.0 };
    auto zActor = CreateArrowActor(E_DIRECTION_Z_PLUS, zColor);
    AddActor(zActor);
}

void MyVtkAxesActor::CereateAxesLabel()
{
}

void MyVtkAxesActor::CereateFace()
{
    double color[3] = { 0, 1, 1 };
    double viewupYPlus[3] = { 0, 1, 0 };
    double viewupZPlus[3] = { 0, 0, 1 };

    //X- face
    {
        double x = 0;
        double origin[3] = { x,m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point1[3] = { x, m_edgeWidgth + m_faceWidgth, m_faceWidgth + m_edgeWidgth };
        double point2[3] = { x, m_edgeWidgth, m_edgeWidgth };
        double viewup[6] = { -1, 0, 0, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_X_MINUS].data());
        AddActor(actor);
    }

    //X+ face
    {
        double x = 2 * m_edgeWidgth + m_faceWidgth;
        double origin[3] = { x, m_edgeWidgth, m_faceWidgth + m_edgeWidgth };
        double point1[3] = { x, m_edgeWidgth, m_edgeWidgth };
        double point2[3] = { x,m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 1, 0, 0, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_X_PLUS].data());
        AddActor(actor);
    }

    //y- face
    {
        double y = 0;
        double origin[3] = { m_edgeWidgth, y, m_edgeWidgth };
        double point1[3] = { m_faceWidgth + m_edgeWidgth,y, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth, y, m_faceWidgth + m_edgeWidgth };
        double viewup[6] = { 0, -1, 0, 0, 0, 1 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_Y_MINUS].data());
        AddActor(actor);
    }

    //y+ face
    {
        double y = 2 * m_edgeWidgth + m_faceWidgth;
        double origin[3] = { m_faceWidgth + m_edgeWidgth,y, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth, y, m_edgeWidgth };
        double point2[3] = { m_faceWidgth + m_edgeWidgth, y, m_faceWidgth + m_edgeWidgth };
        double viewup[6] = { 0, 1, 0, 0, 0, 1 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_Y_PLUS].data());
        AddActor(actor);
    }

    //Z- face
    {
        double z = 0;
        double origin[3] = { m_edgeWidgth + m_faceWidgth,m_edgeWidgth, z };
        double point1[3] = { m_edgeWidgth, m_edgeWidgth, z };
        double point2[3] = { m_edgeWidgth + m_faceWidgth,m_edgeWidgth + m_faceWidgth ,z };
        double viewup[6] = { 0, 0, -1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_Z_MINUS].data());
        AddActor(actor);
    }

    //Z+ face
    {
        double z = 2 * m_edgeWidgth + m_faceWidgth;
        double origin[3] = { m_edgeWidgth, m_edgeWidgth, z };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,m_edgeWidgth, z };
        double point2[3] = { m_edgeWidgth,m_edgeWidgth + m_faceWidgth ,z };
        double viewup[6] = { 0, 0, 1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        FaceAddTexture(actor, m_AxesFaceTextureIconMap[E_DIRECTION_Z_PLUS].data());
        AddActor(actor);
    }
}

void MyVtkAxesActor::CereateEdgeFace()
{
    double color[3] = { 0, 1, 1 };

    //Y top  edge1
    {
        double origin[3] = { 0, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point2[3] = { 0, m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { -1, 1, 0, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  edge2
    {
        double origin[3] = { m_edgeWidgth, m_edgeWidgth + m_faceWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double point2[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 0, 1, 1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  edge3
    {
        double origin[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth,  m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,2 * m_edgeWidgth + m_faceWidgth,  m_edgeWidgth + m_faceWidgth };
        double point2[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double viewup[6] = { 1, 1, 0, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  edge4
    {
        double origin[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, 0 };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth, m_edgeWidgth + m_faceWidgth, 0 };
        double viewup[6] = { 0, 1, -1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }


    //Y middle  edge1
    {
        double origin[3] = { 0, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth,m_edgeWidgth + m_faceWidgth, 0 };
        double point2[3] = { 0, m_edgeWidgth, m_edgeWidgth };
        double viewup[6] = { -1, 0, -1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y middle  edge2
    {
        double origin[3] = { m_edgeWidgth, m_edgeWidgth + m_faceWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double point1[3] = { 0,m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double point2[3] = { m_edgeWidgth, m_edgeWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { -1, 0, 1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y middle  edge3
    {
        double origin[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth,  m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,m_edgeWidgth + m_faceWidgth,  2 * m_edgeWidgth + m_faceWidgth };
        double point2[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth , m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 1, 0, 1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y middle  edge4
    {
        double origin[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, 0 };
        double point1[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth, 0 };
        double viewup[6] = { 1, 0, -1, 0, 1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }


    //Y bottom edge1
    {
        double origin[3] = { 0, m_edgeWidgth, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth,0, m_edgeWidgth };
        double point2[3] = { 0, m_edgeWidgth, m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { -1, -1, 0, 0, -1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom  edge2
    {
        double origin[3] = { m_edgeWidgth, m_edgeWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth,0, m_edgeWidgth + m_faceWidgth };
        double point2[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 0, -1, 1, 0, -1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom  edge3
    {
        double origin[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth,  m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,0,  m_edgeWidgth + m_faceWidgth };
        double point2[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth, m_edgeWidgth };
        double viewup[6] = { 1, -1, 0, 0, -1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom  edge4
    {
        double origin[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth, 0 };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,0, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth, m_edgeWidgth, 0 };
        double viewup[6] = { 0, -1, -1, 0, -1, 0 };

        auto actor = CreateFaceActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }
}

void MyVtkAxesActor::CereateVertexFace()
{
    double color[3] = { 0, 0.8, 1 };

    //Y top  vertex1
    {
        double origin[3] = { 0, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth,m_edgeWidgth + m_faceWidgth, 0 };
        double viewup[6] = { -1, 1, -1, 0, 1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  vertex2
    {
        double origin[3] = { m_edgeWidgth, m_edgeWidgth + m_faceWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double point2[3] = { 0,m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { -1, 1, 1, 0, 1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  vertex3
    {
        double origin[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth,  m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,2 * m_edgeWidgth + m_faceWidgth,  m_edgeWidgth + m_faceWidgth };
        double point2[3] = { m_edgeWidgth + m_faceWidgth,m_edgeWidgth + m_faceWidgth,  2 * m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 1, 1, 1, 0, 1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y top  vertex4
    {
        double origin[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, 0 };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double point2[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth + m_faceWidgth, m_edgeWidgth };
        double viewup[6] = { 1, 1, -1, 0, 1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }


    //Y bottom vertex1
    {
        double origin[3] = { 0, m_edgeWidgth, m_edgeWidgth };
        double point1[3] = { m_edgeWidgth,0, m_edgeWidgth };
        double point2[3] = { m_edgeWidgth, m_edgeWidgth, 0 };
        double viewup[6] = { -1, -1, -1, 0, -1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom  vertex2
    {
        double origin[3] = { m_edgeWidgth, m_edgeWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth,0, m_edgeWidgth + m_faceWidgth };
        double point2[3] = { 0, m_edgeWidgth, m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { -1, -1, 1, 0, -1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom   vertex3
    {
        double origin[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth,  m_edgeWidgth + m_faceWidgth };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,0,  m_edgeWidgth + m_faceWidgth };
        double point2[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth, 2 * m_edgeWidgth + m_faceWidgth };
        double viewup[6] = { 1, -1, 1, 0, -1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }

    //Y bottom   vertex4
    {
        double origin[3] = { m_edgeWidgth + m_faceWidgth, m_edgeWidgth, 0 };
        double point1[3] = { m_edgeWidgth + m_faceWidgth,0, m_edgeWidgth };
        double point2[3] = { 2 * m_edgeWidgth + m_faceWidgth, m_edgeWidgth, m_edgeWidgth };
        double viewup[6] = { 1, -1, -1, 0, -1, 0 };

        auto actor = CreateTriangleActor(origin, point1, point2, color, viewup);
        AddActor(actor);
    }
}

vtkSmartPointer<vtkActor> MyVtkAxesActor::CreateArrowActor(const int& direction, double* color)
{
    vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
    double tipLength = 0.12;
    double tipRadius = tipLength / 2;
    double shaftRadius = 0.01;

    double scale[3] = { 2 * m_boxGap + 1, 1, 1 };
    double position[3] = { -m_boxGap,-m_boxGap, -m_boxGap };

    arrowSource->SetTipLength(tipLength);
    arrowSource->SetTipRadius(tipRadius);
    arrowSource->SetShaftRadius(shaftRadius);

    vtkSmartPointer<vtkPolyDataMapper> arrowMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    arrowMapper->SetInputConnection(arrowSource->GetOutputPort());

    vtkSmartPointer<vtkActor> arrowActor = vtkSmartPointer<vtkActor>::New();
    arrowActor->SetMapper(arrowMapper);
    arrowActor->GetProperty()->SetColor(color);
    arrowActor->GetProperty()->SetColor(color);
    arrowActor->SetPosition(position);
    arrowActor->SetScale(scale);
    arrowActor->SetPickable(false);
    //arrowActor->GetProperty()->SetLighting(false);

    //vtkVectorText 创建文本
    vtkNew<vtkVectorText> textSource;

    // Set the direction of the arrow and create the label accordingly
    switch( direction )
    {
    case E_DIRECTION_X_PLUS:
        textSource->SetText("X");
        position[0] = position[0] + 1 + 0.1;
        position[1] = -0.1;
        position[2] = -0.1;
        break;

    case E_DIRECTION_Y_PLUS:
        textSource->SetText("Y");
        position[1] = position[1] + 1 + 0.1;
        position[0] = -0.1;
        position[2] = -0.1;

        arrowActor->RotateZ(90);
        break;

    case E_DIRECTION_Z_PLUS:
        textSource->SetText("Z");
        position[2] = position[2] + 1 + 0.1;
        position[0] = -0.1;
        position[1] = -0.1;

        arrowActor->RotateY(-90);
        break;
    }

    //create lable mapper and actor
    vtkNew<vtkPolyDataMapper> textMapper;
    textMapper->SetInputConnection(textSource->GetOutputPort());

    vtkSmartPointer<vtkFollower> textActor = vtkSmartPointer<vtkFollower>::New();
    textActor->SetPosition(position);
    textActor->SetMapper(textMapper);
    textActor->SetScale(0.15, 0.15, 0.15);
    textActor->GetProperty()->SetColor(color);
    textActor->GetProperty()->SetLighting(false);
    AddLabel(textActor);
    return arrowActor;
}


vtkSmartPointer<vtkActor> MyVtkAxesActor::CreateFaceActor(double* origin, double* point1, double* point2, double* color, double* viewup)
{
    vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New();
    plane->SetOrigin(origin);
    plane->SetPoint1(point1);
    plane->SetPoint2(point2);

    vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    planeMapper->SetInputConnection(plane->GetOutputPort());

    vtkSmartPointer<vtkActor> planeActor = vtkSmartPointer<vtkActor>::New();
    planeActor->SetMapper(planeMapper);
    planeActor->GetProperty()->SetColor(color);
    planeActor->GetProperty()->SetLighting(false);

    // Set the view up direction
    vtkNew<vtkInformation> actorInfo; // Create a polydata to store everything in.
    actorInfo->Set(m_pDirectionInfoKey, viewup, 6);
    planeActor->GetProperty()->SetInformation(actorInfo);

    return planeActor;
}

vtkSmartPointer<vtkActor> MyVtkAxesActor::CreateTriangleActor(double* origin, double* point1, double* point2, double* color, double* viewup)
{
    vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
    triangle->GetPointIds()->SetId(0, 0);
    triangle->GetPointIds()->SetId(1, 1);
    triangle->GetPointIds()->SetId(2, 2);

    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    points->InsertNextPoint(origin);
    points->InsertNextPoint(point1);
    points->InsertNextPoint(point2);

    vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
    cells->InsertNextCell(triangle);

    vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
    polydata->SetPoints(points);
    polydata->SetPolys(cells);

    vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputData(polydata);

    vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
    actor->SetMapper(mapper);
    actor->GetProperty()->SetColor(color);
    actor->GetProperty()->SetLighting(false);

    // Set the view up direction
    vtkNew<vtkInformation> actorInfo; // Create a polydata to store everything in.
    actorInfo->Set(m_pDirectionInfoKey, viewup, 6);
    actor->GetProperty()->SetInformation(actorInfo);

    return actor;
}

void MyVtkAxesActor::FaceAddTexture(vtkActor* actor, const char* textureFile)
{
    //读取 png 图片 作为纹理   
    vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New();
    reader->SetFileName(textureFile);
    reader->Update();

    vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
    texture->SetInputConnection(reader->GetOutputPort());
    //texture->InterpolateOn();

    actor->SetTexture(texture);
}

